package com.course.cdspringboot.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.mapping.StatementType;

import java.util.List;
import java.util.Map;

@Mapper
public interface TeacherMapper {

    // 教师获取自己的信息
    @Select("SELECT * FROM view_teachers where  uid=#{uid}")
    Map<String, Object> teacherHomeInfo(Long uid);

    // 获取所有教师的信息
    @Select("SELECT * FROM view_teachers")
    List<Map<String, Object>> getAllTeachers();

    // 教师更新自己的信息
    @Update("UPDATE teachers SET phone=#{phone}, email=#{email}, address=#{address} WHERE uid=#{uid}")
    int updatePersonalInfo(Map<String, Object> teacherDetailInfo);

    // 添加教师
    @Select("{call add_teacher(#{p_username}, #{p_password}, #{p_name}, #{p_gender}, #{p_birthdate}, #{p_department_id}, #{p_school_id}, #{p_title_id}, #{p_phone}, #{p_email}, #{p_address}, #{error_code,mode=OUT,jdbcType=INTEGER}, #{error_msg,mode=OUT,jdbcType=VARCHAR})}")
    @Options(statementType = StatementType.CALLABLE)
    void addTeacher(Map<String, Object> teacherInfo);



}
